package com.ohs.ohsoa.system.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.ohs.ohsoa.system.dto.PushlogDto;
import com.ohs.ohsoa.system.service.PushlogService;
import com.ohs.ohsoa.system.vo.PushlogVo;
import com.ohs.ohsoa.utils.auth.UserLoginToken;
import com.ohs.ohsoa.utils.bean.requestBean.PageParam;
import com.ohs.ohsoa.utils.bean.responseBean.ResultBean;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 我的信息
 * @author qhuang
 * @since 2021-11-8
 *
 */

@Api(value = "我的信息controller", tags = "我的信息")
@RestController
@RequestMapping(value = "/pushlog")
public class PushlogController {

    @Resource
    private PushlogService pushlogService;

    /**
     * 获取列表信息
     * @param pageParam 检索用参数
     * @return 列表信息
     */
    @UserLoginToken
    @PostMapping(value = "/select/list")
    @ApiOperation(httpMethod = "POST", value = "获取列表信息")
    public ResultBean<PageInfo<PushlogVo>> pushlogSelectList(@RequestBody PageParam<PushlogDto> pageParam){
        List<PushlogVo> res = pushlogService.pushlogSelectList(pageParam);
        return ResultBean.success(new PageInfo<>(res));
    }

    /**
     * 将我的消息变为已读
     * @param pushlogDto 我的消息参数
     * @return 更新信息
     */
    @UserLoginToken
    @PutMapping(value = "/update/readflg")
    @ApiOperation(httpMethod = "PUT", value = "将我的消息变为已读")
    public ResultBean<Boolean> pushlogUpdateReadflg(@RequestBody PushlogDto pushlogDto){
        return ResultBean.success(pushlogService.pushlogUpdateReadflg(pushlogDto));
    }

    /**
     * 首页查询我的消息个数
     * @param pushlogDto 消息列表数据
     * @return 我的消息个数
     */
    @UserLoginToken
    @PostMapping(value = "/selectnotreadcount")
    @ApiOperation(httpMethod = "POST", value = "首页查询我的消息个数")
    public ResultBean<Integer> pushlogselectnotreadcount(@RequestBody PushlogDto pushlogDto){
        return ResultBean.success(pushlogService.pushlogselectnotreadcount(pushlogDto));
    }

}
